package db;

import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;

public class AICommand {

	public static ResultSet getAll() {
		
		ResultSet rs = null;
		
		
		try {
			Class.forName("com.mysql.jdbc.Driver").newInstance();
					
			String stmt = "SELECT * from ai";
    	
			PreparedStatement get = DriverManager.getConnection(
					"jdbc:mysql://78.46.51.229:3306/yoman07_pawel?autoReconnect=true", "yoman07_pawel",  "iZLAXU79").prepareStatement(stmt);

			rs = get.executeQuery();
		} catch (InstantiationException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (IllegalAccessException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (ClassNotFoundException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return rs;
	}
	
public static ResultSet getSpecified(String s) {
		
		ResultSet rs = null;
		
		
		try {
			Class.forName("com.mysql.jdbc.Driver").newInstance();
					
			String stmt = "SELECT * from ai where " + s;
    	
			PreparedStatement get = DriverManager.getConnection(
					"jdbc:mysql://78.46.51.229:3306/yoman07_pawel?autoReconnect=true", "yoman07_pawel",  "iZLAXU79").prepareStatement(stmt);

			rs = get.executeQuery();
		} catch (InstantiationException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (IllegalAccessException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (ClassNotFoundException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return rs;
	}
}
